package com.example.filetransfer.publicsource.fileutils;

import java.io.File;


public class DiffFileThread extends Thread {
    private DirDiffer mDirDiffer;
    private XmlReader mXmlReader;
    private String mTreeFilePath;
    private String mComparePath;

    public DiffFileThread(String treefile, String comparePath) {
        mDirDiffer = new DirDiffer();
        mXmlReader = new XmlReader();
        mTreeFilePath = treefile;
        mComparePath = comparePath;
    }

    @Override
    public void run() {
        mXmlReader.parserXml(mTreeFilePath);
        Dir treeFileDir = mXmlReader.getRootDir();
        treeFileDir.clearUp();
        Dir comparePathDir = DirUtils.scanDir(null, new File(mComparePath));
        comparePathDir.clearUp();
        mDirDiffer.compareDirFile(comparePathDir, treeFileDir);
        System.out.println("changedfile" + mDirDiffer.getChangedFiles());
        System.out.println("new files" + mDirDiffer.getNewFiles());
        System.out.println("delete files" + mDirDiffer.getDeletedFils());
    }

    public static void main(String[] args) {
        new DiffFileThread("/new_disk2/sync/.filetree.xml", "/new_disk2/sync2").start();
    }
}
